package com.atgugui.edustatistics.controller;


import com.atgugui.commonutils.Result;
import com.atgugui.edustatistics.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-09-17
 */
@Api(tags = "统计分析控制层")
@RestController
@RequestMapping("/edustatistics/statistics-daily")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    /**
     * 2021-09-10
     * @param day
     * @return
     */
    @ApiOperation(value = "统计某一天的注册人数")
    @GetMapping("/countRegister/{day}")
    public Result countRegister(@PathVariable String day) {
        statisticsDailyService.countRegister(day);
        return Result.ok();
    }

    @ApiOperation(value = "统计")
    @GetMapping("/statistics/{type}/{begin}/{end}")
    public Result statisticsData(@PathVariable String type,
                                 @PathVariable String begin,
                                 @PathVariable String end) {
        HashMap<String,Object> staMap = statisticsDailyService.statisticsData(type,begin,end);
        return Result.ok().data(staMap);
    }
}

